]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
calendar-server: Read timezone from the calendar, not its timezone cache
authorMilan Crha <mcrha@redhat.com>
Wed, 2 Feb 2022 14:34:03 +0000 (15:34 +0100)
committerMarge Bot <marge-bot@gnome.org>
Thu, 3 Feb 2022 17:18:48 +0000 (17:18 +0000)
The calendar's timezone cache holds only timezones already received
or added to the calendar, thus when asking it for a timezone for "the first
time", it returns NULL and a wrong timezone is used instead.
The get_timezone() does not do any I/O when the timezone is already cached
on the client side, thus it's fine to use it.

This could exhibit with non-recurring events, which use custom time zones,
in which case the event is shown in a wrong time.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2145>

src/calendar-server/gnome-shell-calendar-server.c

index 5d15e2ae6028b88ce39eb6444eeb5454278ca476..f1980c633c4a6436a17c0e794ad4a9128a97fef6 100644 (file)
@@ -123,7 +123,6 @@ get_time_from_property (ECalClient            *cal,
 {
   ICalProperty  *prop;
   ICalTime      *itt;
-  ICalParameter *param;
   ICalTimezone  *timezone = NULL;
 
   prop = i_cal_component_get_first_property (icomp, prop_kind);
@@ -132,17 +131,24 @@ get_time_from_property (ECalClient            *cal,
 
   itt = get_prop_func (prop);
 
-  param = i_cal_property_get_first_parameter (prop, I_CAL_TZID_PARAMETER);
-  if (param)
-    timezone = e_timezone_cache_get_timezone (E_TIMEZONE_CACHE (cal), i_cal_parameter_get_tzid (param));
-  else if (i_cal_time_is_utc (itt))
+  if (i_cal_time_is_utc (itt))
     timezone = i_cal_timezone_get_utc_timezone ();
   else
+   {
+      ICalParameter *param;
+
+      param = i_cal_property_get_first_parameter (prop, I_CAL_TZID_PARAMETER);
+      if (param && !e_cal_client_get_timezone_sync (cal, i_cal_parameter_get_tzid (param), &timezone, NULL, NULL))
+        print_debug ("Failed to get timezone '%s'\n", i_cal_parameter_get_tzid (param));
+
+      g_clear_object (&param);
+   }
+
+  if (timezone == NULL)
     timezone = default_zone;
 
   i_cal_time_set_timezone (itt, timezone);
 
-  g_clear_object (&param);
   g_clear_object (&prop);
 
   *out_itt = itt;